package com.ay277.htqoa.quartz.entiy;

import com.ay277.htqoa.quartz.entiy.MyJob1;
import org.quartz.Scheduler;
import org.quartz.SchedulerFactory;
import org.quartz.SimpleTrigger;
import org.quartz.impl.JobDetailImpl;
import org.quartz.impl.StdSchedulerFactory;
import org.quartz.impl.triggers.SimpleTriggerImpl;

import java.util.Date;

/**
 * Created by accp on 2016/12/21.
 */
public class Test  {
    public static void main(String[] args) throws Exception{
        JobDetailImpl jd=new JobDetailImpl();
        jd.setName("myjob");
        jd.setJobClass(MyJob1.class);

        SimpleTriggerImpl st=new SimpleTriggerImpl();
        st.setName("myjob");
        //st.setRepeatCount(-1);
        st.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
        st.setRepeatInterval(3000);
        st.setJobName("myjob");
        st.setStartTime(new Date());

        SchedulerFactory sf=new StdSchedulerFactory();
        Scheduler s=sf.getScheduler();
        s.scheduleJob(jd,st);
        s.start();
        System.in.read();
        s.shutdown();
    }
}
